import 'package:flutter/material.dart';

class TextDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Text文本"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            //textAlign 设置文本方向  居左  居右  居中
            new Text("Hello Flutter", textAlign: TextAlign.left),
            new Text(
              "Hello Flutter" * 15,
              maxLines: 2, //设置支持两行
              overflow: TextOverflow.ellipsis, //设置文本后显示...
            ),
            // textScaleFactor设置文本缩放比例
            new Text(
              "Hello Flutter",
              textScaleFactor: 1.5,
            ),
            //textStyle  设置文本样式
            Text(
              "Hello Flutter",
              style: TextStyle(
                  color: Colors.black,
                  fontSize: 18.0,
                  //设置行高
                  height: 1.2,
                  fontFamily: "Courier",
                  background: new Paint()..color = Colors.yellow,
                  decoration: TextDecoration.underline,
                  decorationStyle: TextDecorationStyle.dashed),
            ),
            /**TextSpan  控制文本*/
            new Text.rich(TextSpan(children: [
              TextSpan(text: "hello:"),
              TextSpan(text: "Flutter", style: TextStyle(color: Colors.blue))
            ])),
            /**DefaultTextStyle*/
            DefaultTextStyle(
                style: TextStyle(
                  color: Colors.red,
                  fontSize: 20.0,
                ),
                textAlign: TextAlign.start,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text("Hello World"),
                    Text("Hello World"),
                    Text("Hello World",style: TextStyle(
                      inherit: false,  //不继承默认样式
                      color: Colors.grey
                    ),),
                  ],
                ))
          ],
        ),
      ),
    );
  }
}
